<% layout('/layout/default.html', {title: '文件管理', libs: ['zTree','validate']}){ %>
<div class="main-content">
	<div class="card-header">
		<i class="fa fa-sitemap"></i>移动文件
	</div>
	<#form:form id="inputForm" model="${sysFile}" class="form-horizontal" action="${ctx}/file/sysFile/save" method="post">
		<div class="card-body">
			<#form:hidden path="id"/>
			<div class="row">
				<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
					<div class="form-group row">
						<label class="col-form-label col-lg-4 col-md-4 text-right" title="当前所在文件夹">
							<span class="required " aria-required="true">*</span> 当前文件夹：<i class="fa icon-question hide"></i></label>
						<div class="col-lg-8 col-md-8 ">
							<div class="form-control form-control-sm " readonly="readonly">
								${sysFile.fileTreeName}
							</div>
						</div>
					</div>
				</div>
				<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
					<div class="form-group row">
						<label class="col-form-label col-lg-4 col-md-4 text-right" title="文件名">
							<span class="required " aria-required="true">*</span> 文件名：<i class="fa icon-question hide"></i></label>
						<div class="col-lg-8 col-md-8 ">
							<#form:input path="name" class="form-control form-control-sm readonly" maxlength="100" />
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
					<div class="form-group row">
						<label class="col-form-label col-lg-4 col-md-4 text-right" title="选择移动到目标文件夹">
							<span class="required " aria-required="true">*</span> 移动到 <i class="fa icon-question hide"></i></label>
						<div class="col-lg-8 col-md-8 ">
							<div class="zTreeDemoBackground left">
								<ul id="treeDemo" class="ztree"></ul>
							</div>
						</div>
					</div>
				</div>
				<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
					<div class="form-group row">
						<label class="col-form-label col-lg-4 col-md-4 text-right" title="选择目标文件夹">
							<span class="required " aria-required="true">*</span> 目标文件夹 <i class="fa icon-question hide"></i></label>
						<div class="col-lg-8 col-md-8 ">
							<div class="form-control form-control-sm " readonly="readonly" id="log_down">
								当前未选择目标文件夹
							</div>
							<input type="hidden" name="fileTreeId" id="destId"/>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="box-footer">
			<div class="row">
				<div class="offset-md-2 col-md-10">
				<% if (hasPermi('file:sysFile:edit')){ %>
					<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> 保 存</button>
				<% } %>
					<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="window.parent.closeCurrentTabPage();"><i class="fa fa-reply-all"></i> 关 闭</button>
				</div>
			</div>
		</div>
	</#form:form>
</div>
<script type="text/javascript">
		var setting = {
			data: {
				simpleData: {
					enable: true
				}
			},
			callback: {
				onMouseDown: onMouseDown
			}
		};

		var log, className = {down:"dark", up:"dark", right:"dark"};
		
		function onMouseDown(event, treeId, treeNode) {
			console.log(treeNode);
			showLog(treeNode?treeNode.name:"root",treeNode.id,"down");
		}
		
		function showLog(str,val,logType) {
			log = $("#log" + "_" + logType);
			dest = $("#destId");
			dest.val(val);
			log.html(str);
		}
		function getTime() {
			var now= new Date(),
			h=now.getHours(),
			m=now.getMinutes(),
			s=now.getSeconds(),
			ms=now.getMilliseconds();
			return (h+":"+m+":"+s+ " " +ms);
		}
		$(document).ready(function(){
			 $.ajax({
	                type:"POST",
	                url:"${ctx}/filetree/sysFileTree/treeData",
	                dataType:"json",
	                success:function(data){
	                	var ztree = $.fn.zTree.init($("#treeDemo"), setting, data);
	                	ztree.expandAll(true);
	                }
	            });
		});
</script>
<% } %>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == 'true'){
				window.parent.closeCurrentTabPage(window.parent.refreshTab);
			}
		});
    }
});
</script>